package org.apache.ibatis.common.logging.jdk14;

import org.apache.ibatis.common.logging.Log;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @Name Jdk14LoggingImpl
 * @Description: [Jdk 14 logging 日志框架] 实现类
 * @Version v1.0.0
 * @Author: lichao
 * @Date: 2024-05-15 16:10:29
 **/
public class Jdk14LoggingImpl implements Log {
    private final Logger log;

    public Jdk14LoggingImpl(String clazz) {
        this.log = Logger.getLogger(clazz);
    }

    @Override
    public boolean isDebugEnabled() {
        return log.isLoggable(Level.FINE);
    }

    @Override
    public boolean isTraceEnbaled() {
        return log.isLoggable(Level.FINER);
    }

    @Override
    public void error(String msg, Throwable e) {
        log.log(Level.SEVERE, msg, e);
    }

    @Override
    public void error(String msg) {
        log.log(Level.SEVERE, msg);
    }

    @Override
    public void warn(String msg) {
        log.log(Level.WARNING, msg);
    }

    @Override
    public void debug(String msg) {
        log.log(Level.FINE, msg);
    }

    @Override
    public void trace(String msg) {
        log.log(Level.FINER, msg);
    }
}

